The area of the circle circumscribed in the square of side 2 and whose equation is \(x^2 + y^2 = 0\) as show in the figure below (radius = 1; center = (0,0)):
It can be calculated like:
The probability that a point falls into circle:
\(P \{(X,Y) \ into \ circle \}\)
\(P \{\ X^2 + Y^2 \leq 1 \} = \frac{\pi}{4}\)
Defined as:
\begin{equation} I= \begin{cases} 1, & \text{if}\ \ X^2 + Y^2 \leq 1 \\ 0, & \text{otherwise} \end{cases} \end{equation}
\( E[I] = P \{\ X^2 + Y^2 \leq 1 \} = \pi/4 \)
Here's implementation in Python:
import random as rand
u = lambda : rand.uniform(-1,1) # Helper function and parameter
run = 100000 # Simulation run length
guess = sum([1 for x in range(run) if u()**2 + u()**2 <= 1])
piNumber = 2*2*guess/run # Clear equation
print ( piNumber )
Aproximately: 3,14...
Hiya. I'm Ronald, an Industrial Engineer from Colombia. Hope you enjoyed my ad-free, bullshit-free site. If you liked it, tell someone about it.